<script type="text/javascript" src="java/formval.js"></script>
<script type="text/javascript">
function validateOnSubmit(formElem) {
	var elem;
	var errs=0;
	if (!validatePresent(formElem.KulturshowsName,  'KulturshowsNameError', true))  		errs = 1;
	
	if (errs==0){
		formElem.submit();
	}
};
</script>
<?php

if(!empty($_SESSION["CMS_User"]["ID"])){
	$FirmaID = $_GET["FirmaID"];
	$AbteilungID = $_GET["AbteilungID"];
	$KulturshowsID = $_GET['KulturshowsID'];
	if($_POST){
		if(!empty($_POST["KulturshowsID"])){//edit
			if(!empty($_POST["KulturshowsName"])){
				$KulturshowsID=$_POST["KulturshowsID"];
				$sql="update kulturshows set
				AbteilungID= $AbteilungID
				,KulturshowsName='".$_POST["KulturshowsName"]."'
				,DataOffnungZeiten='".$_POST['DataOffnungZeiten']."'
				,Preis='".$_POST["Preis"]."'
				,Info='".$_POST["Info"]."'
				where ID=$KulturshowsID";
				//echo $sql;
				$_rd=mysql_query($sql,$_db_link);
			}
		}else {//Add
			if(!empty($_POST["KulturshowsName"])){
				$sql="insert into
			     Kulturshows (AbteilungID,KulturshowsName,DataOffnungZeiten,Preis,Info) 
				values($AbteilungID
				,'".$_POST["KulturshowsName"]."'
				,'".$_POST["DataOffnungZeiten"]."'
				,'".$_POST["Preis"]."'
				,'".$_POST["Info"]."')";
				//echo $sql;
				$_rd= mysql_query($sql,$_db_link);
				$KulturshowsID = mysql_insert_id();
			}
		}
	}
}
if($AbteilungID!= NULL && $AbteilungID!=0){

	if($KulturshowsID!=NULL && $KulturshowsID!=0){
		$sql="select * FROM kulturshows WHERE ID=$KulturshowsID";
		$_rd= mysql_query($sql,$_db_link);
		if($_rd){
			$daten=mysql_fetch_array($_rd,MYSQL_ASSOC);
		}
	}
	?>
<div style="width: 100%; background-color: #F1EEF3; margin: 0px">
<table class="tableEdit">
<?PHP if(isset($KulturshowsID)){ ?>
	<tr>
		<td class="lableEdit"><?PHP  LangText("ID");?>:</td>
		<td class="inputEdit"><input type="text" name="KulturshowsID"
			id="KulturshowsID" READONLY value='<?PHP echo $KulturshowsID; ?>' /></td>
		<td class="validateEdit"></td>
	</tr>
	<?PHP } ?>
	<tr>
		<td class="lableEdit"><?PHP  LangText("AbteilungID");?>:</td>
		<td class="inputEdit"><input type="text" name="AbteilungID"
			id="AbteilungID" READONLY value='<?PHP echo $AbteilungID; ?>' /></td>
		<td class="validateEdit"></td>
	</tr>
	<tr>
		<td class="lableEdit"><?PHP  LangText("KulturshowsName");?>:*</td>
		<td class="inputEdit"><input type="text" name="KulturshowsName"
			id="KulturshowsName"
			onchange="validatePresent(this, 'KulturshowsNameError');"
			value='<?PHP echo $daten["KulturshowsName"]; ?>' /></td>
		<td class="validateEdit"><input type="label" DISABLED
			id="KulturshowsNameError"
			value='<?PHP LangText("KulturshowsNameError");?>' /></td>
	</tr>
	<tr>
		<td class="lableEdit"><?PHP  LangText("DataOffnungZeiten");?>:</td>
		<td class="inputEdit"><input name="DataOffnungZeiten"
			id="DataOffnungZeiten"
			value='<?PHP echo $daten["DataOffnungZeiten"]; ?>' /></td>
		<td class="validateEdit"></td>
	</tr>
	<tr>
		<td class="lableEdit"><?PHP  LangText("Preis");?>:</td>
		<td class="inputEdit"><input name="Preis" id="Preis"
			value='<?PHP echo $daten["Preis"]; ?>' /></td>
		<td class="validateEdit"></td>
	</tr>
	<tr>
		<td class="lableEdit"><?PHP  LangText("Info");?>:</td>
		<td class="inputEdit"><textarea name="Info" id="Info"><?PHP echo $daten["Info"]; ?></textarea></td>
		<td class="validateEdit"></td>
	</tr>


	<tr>
		<td class="lableEdit"></td>
		<td class="inputEdit"><input type="button"
			onclick="validateOnSubmit(this.form);" class="BootenLink"
			value='<?PHP if($KulturshowsID!=NULL && $KulturshowsID != 0 ){LangText("Bearbeiten");}else{ LangText("Himzufugen");}?>' />
		<input type="button"
			onclick="window.location='index.php?tag=<?PHP echo $_GET['tag']; ?>&page=AbteilungEditPro&FirmaID=<?PHP echo $FirmaID; ?>&AbteilungID=<?PHP echo $AbteilungID; ?>&MoudeTagID=<?PHP echo $_GET['MoudeTagID']; ?>'"
			class="BootenLink" value='<?PHP LangText("Abbrechen");?>' /></td>
		<td class="validateEdit"></td>
	</tr>
</table>
</div>

<?php
}
?>
